/******************************************************************************/
package jamie.org.sil.www.usxUtils;

import java.util.HashMap;



/******************************************************************************/
/**
 * Miscellaneous information about USX tags.
 *
 * @author ARA "Jamie" Jamieson
*/

public class UsxTagDetails
{
  /****************************************************************************/
  /****************************************************************************/
  /**                                                                        **/
  /**                               Public                                   **/
  /**                                                                        **/
  /****************************************************************************/
  /****************************************************************************/

  /****************************************************************************/
  public enum Canonicity { C_Canonical, C_NonCanonical, C_Current };


  /****************************************************************************/
  /**
     Singleton.

     @return Singleton instance.
  */

  public static UsxTagDetails instance ()
  {
    if (null == m_Instance) m_Instance = new UsxTagDetails();
    return m_Instance;
  }


  /****************************************************************************/
  /**
     Gets the canonicity for a given USX tag name.

     @param usxTagName USX tag name (eg it, bdit, etc).
     
     @return Canonicity.
  */

  public Canonicity getCanonicity (String style)
  {
    if (m_TagDetails.containsKey(style))
      return m_TagDetails.get(style).m_Canonicity;
    else
      return Canonicity.C_Current; // Covers USX, book, etc.
  }

  
  /****************************************************************************/
  /**
     Gets the USX XML tag name for a given USX tag (para, char, etc).

     @param usxTagName USX tag name (eg it, bdit, etc).
     
     @return USX XML tag name.
     
     @throws ConverterException
  */

  public String getUsxXmlTag (String usxTagName) throws ConverterException
  {
    if (m_TagDetails.containsKey(usxTagName))
      return m_TagDetails.get(usxTagName).m_UsxXmlTag;
    else
      throw new ConverterException(ConverterException.Action.AbandonFileWhenever,
                                   ConverterException.Log.Error,
                                   "Unknown USX tag " + usxTagName);
  }




  /****************************************************************************/
  /****************************************************************************/
  /**                                                                        **/
  /**                               Private                                  **/
  /**                                                                        **/
  /****************************************************************************/
  /****************************************************************************/

  /****************************************************************************/
  /* Constructor. */

  private UsxTagDetails ()
  {
    m_TagDetails.put("bra_introductoryMaterial", new TagDetails("userDefinedPara", Canonicity.C_Current));
    m_TagDetails.put("ket_introductoryMaterial", new TagDetails("userDefinedPara", Canonicity.C_Current));
    m_TagDetails.put("bra_ul", new TagDetails("userDefinedPara", Canonicity.C_Current));
    m_TagDetails.put("ket_ul", new TagDetails("userDefinedPara", Canonicity.C_Current));
    m_TagDetails.put("id", new TagDetails("book", Canonicity.C_Canonical));
    m_TagDetails.put("c", new TagDetails("chapter", Canonicity.C_Canonical));
    m_TagDetails.put("abbreviation", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("add", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("addpn", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("bd", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("bdit", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("bk", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("ca", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("dc", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("efm", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("em", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("fdc", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("fk", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("fl", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("fm", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("fp", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("fq", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("fqa", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("fr", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("ft", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("fv", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("ior", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("iqt", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("it", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("k", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("label", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("nd", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("ndx", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("no", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("ord", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("pn", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("pro", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("qac", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("qs", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("qt", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("rem", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("rq", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("sc", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("sc", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("sig", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("sls", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("tc1", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("tc2", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("tc3", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("tc4", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("tcr1", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("tcr2", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("tcr3", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("tcr4", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("th1", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("th2", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("th3", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("th4", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("thr1", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("thr2", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("thr3", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("thr4", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("tl", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("va", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("vp", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("w", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("wg", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("wh", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("wj", new TagDetails("char", Canonicity.C_Current));
    m_TagDetails.put("xdc", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("xk", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("xnt", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("xo", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("xot", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("xq", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("xt", new TagDetails("char", Canonicity.C_NonCanonical));
    m_TagDetails.put("f", new TagDetails("note", Canonicity.C_NonCanonical));
    m_TagDetails.put("fe", new TagDetails("note", Canonicity.C_NonCanonical));
    m_TagDetails.put("x", new TagDetails("note", Canonicity.C_NonCanonical));
    m_TagDetails.put("b", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("breaking_verse_paragraph", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("cd", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("cl", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("cl1", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("cl2", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("cls", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("cp", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("d", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("h", new TagDetails("para", Canonicity.C_Canonical));
    m_TagDetails.put("h1", new TagDetails("para", Canonicity.C_Canonical));
    m_TagDetails.put("h2", new TagDetails("para", Canonicity.C_Canonical));
    m_TagDetails.put("h3", new TagDetails("para", Canonicity.C_Canonical));
    m_TagDetails.put("ib", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("ide", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("ie", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("iex", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("ili", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("ili1", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("ili2", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("im", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("imi", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("imq", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("imt", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("imt1", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("imt2", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("imt3", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("imt4", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("imte", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("imte1", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("imte2", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("io", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("io1", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("io2", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("io3", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("io4", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("iot", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("ip", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("ipi", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("ipq", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("ipr", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("iq", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("iq1", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("iq2", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("iq3", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("is", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("is1", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("is2", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("k1", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("k2", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("li", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("li1", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("li2", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("li3", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("li4", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("lit", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("m", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("mi", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("mr", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("ms", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("ms1", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("ms2", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("ms3", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("mt", new TagDetails("para", Canonicity.C_Canonical));
    m_TagDetails.put("mt1", new TagDetails("para", Canonicity.C_Canonical));
    m_TagDetails.put("mt2", new TagDetails("para", Canonicity.C_Canonical));
    m_TagDetails.put("mt3", new TagDetails("para", Canonicity.C_Canonical));
    m_TagDetails.put("mt4", new TagDetails("para", Canonicity.C_Canonical));
    m_TagDetails.put("mte", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("mte1", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("mte2", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("nb", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("no_break_verse_paragraph", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("p", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("p_introduction", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("p_letter_closing", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("p_letter_opening", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("p_variant", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("p1", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("p2", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("pb", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("pc", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("periph", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("pi", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("pi1", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("pi2", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("pi3", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("pm", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("pmc", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("pmo", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("pmr", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("psa", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("psa_conclusion", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("psa_continuation", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("psa_introduction", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("q", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("q1", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("q2", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("q3", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("q4", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("qa", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("qc", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("qm", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("qm1", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("qm2", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("qm3", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("qr", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("qr_attribution", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("qr_refrain", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("qr_selah", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("r", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("rem", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("restore", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("s", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("s_variant", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("s_variant_tail", new TagDetails("para", Canonicity.C_NonCanonical));
    m_TagDetails.put("s1", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("s2", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("s3", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("s4", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("sp", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("sr", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("toc1", new TagDetails("para", Canonicity.C_Canonical));
    m_TagDetails.put("toc2", new TagDetails("para", Canonicity.C_Canonical));
    m_TagDetails.put("toc3", new TagDetails("para", Canonicity.C_Canonical));
    m_TagDetails.put("tr", new TagDetails("para", Canonicity.C_Current));
    m_TagDetails.put("v", new TagDetails("verse", Canonicity.C_Canonical));
  }


  /****************************************************************************/
  private class TagDetails
  {
    private TagDetails (String usxXmlTag, Canonicity canonicity) { m_UsxXmlTag = usxXmlTag; m_Canonicity = canonicity; }
    private Canonicity m_Canonicity = Canonicity.C_Current;
    private String m_UsxXmlTag = null;
  }

  
  /****************************************************************************/
  private HashMap<String, TagDetails> m_TagDetails = new HashMap<String, TagDetails>(400);
  private static UsxTagDetails m_Instance = null;
}
